<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/11/2 0002
 * Time: 上午 10:04
 */

namespace App\Http\Controllers\Admin;


use App\Http\Controllers\Controller;

class BaseController extends Controller
{
    /**
     * @description:操作成功处理
     * @author: hkw <hkw925@qq.com>
     * @param $message
     * @param null $data
     * @param string $url
     * @return \Illuminate\Http\JsonResponse
     */
    protected function success($message, $data = null, $url = ''){
        $result = array('code' => 0, 'msg' => $message, 'url' => $url);
        if ($data) $result['data'] = $data;
        return response()->json($result);
    }

    /**
     * @description:操作失败处理
     * @author: hkw <hkw925@qq.com>
     * @param $code
     * @param $message
     * @param null $data
     * @param string $url
     * @return \Illuminate\Http\JsonResponse
     */
    protected function error($code, $message, $data = null, $url = ''){
        $result = array('code' => $code, 'msg' => $message, 'url' => $url);
        if ($data) $result['data'] = $data;
        return response()->json($result);
    }
}